/**
 * 
 */
package com.googlecode.pcapj.bridj;

import org.bridj.Pointer;
import org.bridj.StructObject;
import org.bridj.ann.Field;

public class uint16_t extends StructObject {
    public uint16_t() { super(); }
    public uint16_t(Pointer<? extends StructObject> pointer) { super(pointer); }

    @Field(0) 
    public byte byte1() {
            return this.io.getByteField(this, 0);
    }
    @Field(0) 
    public uint16_t byte1(byte byte1) {
            this.io.setByteField(this, 0, byte1);
            return this;
    }

    @Field(1) 
    public byte byte2() {
            return this.io.getByteField(this, 1);
    }
    @Field(1) 
    public uint16_t byte2(byte byte2) {
            this.io.setByteField(this, 1, byte2);
            return this;
    }
    public short toShort(Endian endian){
    	return (short)toInt(endian);
    }
    public int toInt(Endian endian){
    	int n ;
    	int byte1 = byte1() & 0xff;
    	int byte2 = byte2() & 0xff;
    	if(Endian.BIG.equals(endian)){
    		n = byte1 << 8 | byte2; 
    		
    	}else{
    		n = byte2 << 8 | byte1;
    		
    	}
    	return n;
    }
}
